package br.com.Orange.util;

import br.com.Orange.util.negocio.exception.DadoInvalidoException;

public class Util {
	 public static int readInt() throws DadoInvalidoException
	    {
	        byte[] bytes=new byte[160];
	        try 
	        {
	            System.in.read(bytes);
	        
	         
	        char[]caracts=new char[160];
	        for(int i=0;i<160;i++)
	        caracts[i]=(char)bytes[i];
	        String str=new String(caracts);
	        return(Integer.parseInt(str.trim()));
	        
	        }
	        catch(Exception ex){
	        	throw new DadoInvalidoException();
	        }
	    }

	    public static double readDbl() throws DadoInvalidoException
	    {
	        byte[] bytes=new byte[160];
	        try 
	        {
	            System.in.read(bytes);
	        
	        
	        char[] caracts=new char[160];
	        for (int i=0;i<160;i++)
	        caracts[i]=(char) bytes[i];
	        String str=new String(caracts);
	        return(Double.valueOf(str.trim())).doubleValue();
	        
	    	}
        	catch(Exception ex){
        		throw new DadoInvalidoException();
        	}
	        
	    }

	    public static String readStr() 
	    {
	        byte[] bytes=new byte[160];
	        try 
	        {
	            System.in.read(bytes);
	        }
	        catch(Exception e) 
	        {
	            System.out.println ("ERRO...: " + e);
	        }
	        char[] caracts=new char[160];
	        for (int i=0;i<160;i++)
	        caracts[i]=(char) bytes[i];
	        String str=(new String(caracts)).trim();
	        return str;
	    }

	    public static void waitEnter()
	    {
	        byte[] bytes=new byte[160];
	        try
	        {
	            System.in.read(bytes);
	        }
	        catch(Exception e)
	        {
	            System.out.println ("ERRO...: " + e);
	        }
	    }


	
}
